import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
import tensorflow as tf

class NN(object):
    
    def __init__(self, data):
        self.loaded_model = tf.keras.models.load_model('NN/my_model.keras')  # 加载预训练模型，路径需根据实际情况修改

  
def get_hourly_trend(self):
        n_steps = 7  # 长度七天
        data = self.df.values
        X, y = self.create_dataset(self.df.values, n_steps)  # 创建数据集

        # 数据划分
        train_size = int(len(X) * 0.8)
        X_train, X_test = X[:train_size], X[train_size:]
        y_train, y_test = y[:train_size], y[train_size:]

        model = tf.keras.models.Sequential()
        model.add(tf.keras.layers.LSTM(50, activation='relu', return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))
        model.add(tf.keras.layers.LSTM(50, activation='relu'))
        model.add(tf.keras.layers.Dense(18))
        model.compile(optimizer='adam', loss='mse')
        model.fit(X_train, y_train, epochs=50, validation_data=(X_test, y_test))


 

